package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.ZhwyChargedata;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ZhwyMeterreadingdata;
import com.ruoyi.service.IZhwyMeterreadingdataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抄表数据表Controller
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/feeSettings/meterreadingdata")
public class ZhwyMeterreadingdataController extends BaseController
{
    @Autowired
    private IZhwyMeterreadingdataService zhwyMeterreadingdataService;

    /**
     * 查询抄表数据表列表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        startPage();
        List<ZhwyMeterreadingdata> list = zhwyMeterreadingdataService.selectZhwyMeterreadingdataList(zhwyMeterreadingdata);
        return getDataTable(list);
    }

    /**
     * 导出抄表数据表列表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:export')")
    @Log(title = "抄表数据表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        List<ZhwyMeterreadingdata> list = zhwyMeterreadingdataService.selectZhwyMeterreadingdataList(zhwyMeterreadingdata);
        ExcelUtil<ZhwyMeterreadingdata> util = new ExcelUtil<ZhwyMeterreadingdata>(ZhwyMeterreadingdata.class);
        util.exportExcel(response, list, "抄表数据表数据");
    }

    /**
     * 获取抄表数据表详细信息
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zhwyMeterreadingdataService.selectZhwyMeterreadingdataById(id));
    }

    /**
     * 新增抄表数据表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:add')")
    @Log(title = "抄表数据表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        return toAjax(zhwyMeterreadingdataService.insertZhwyMeterreadingdata(zhwyMeterreadingdata));
    }

    /**
     * 修改抄表数据表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:edit')")
    @Log(title = "抄表数据表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        return toAjax(zhwyMeterreadingdataService.updateZhwyMeterreadingdata(zhwyMeterreadingdata));
    }

    /**
     * 删除抄表数据表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:remove')")
    @Log(title = "抄表数据表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zhwyMeterreadingdataService.deleteZhwyMeterreadingdataByIds(ids));
    }

    /**
     * 批量新增抄表数据
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:meterreadingdata:adds')")
    @Log(title = "收费数据", businessType = BusinessType.INSERT)
    @PostMapping("/adds")
    public AjaxResult adds(@RequestBody List<ZhwyMeterreadingdata> meterreadingdataList) {

        for (ZhwyMeterreadingdata zhwyMeterreadingdata : meterreadingdataList) {
            System.out.println(zhwyMeterreadingdata);
        }
        return toAjax(zhwyMeterreadingdataService.batchInsertZhwyMeterreadingdata(meterreadingdataList));
    }
}
